Current assembly systems are handling the increased requirements for mass customization with difficulties and need to be updated with new approaches and technologies. Cyber-Physical Systems (CPS) auto-configuration is regarded as an important asset towards automation components, which autonomously embed themselves into the system. In this context, knowledge-based technologies pave the way for highly flexible and reconfigurable CPS. This paper introduces and demonstrates a model-driven engineering approach for automatically configuring the control layer of a CPS based on knowledge representation of the environment and component capabilities. The approach encompasses a control architecture that is tested in two industrial use cases. The first case employs a configuration infrastructure for control software based on IEC 61499 to automatically configure the hardwarenear control layer of a CPS within an assembly line. The second case is concerned with autonomously generating assembly plans, which are then transformed into actions that an industrial robot sequentially executes.