Scheduling spectrum access and allocating power and rate resources are tasks affecting critically the performance of wireless cognitive radio (CR) networks. The present contribution develops a primal-dual optimization framework to schedule any-to-any CR communications based on orthogonal frequency division multiple access (OFDMA) and allocate power so as to maximize the weighted average sum-rate of all users. Fairness is ensured among CR communicators and possible hierarchies are respected by guaranteeing minimum rate requirements for primary users while allowing secondary users to access the spectrum opportunistically. The framework leads to an iterative channel-adaptive distributed algorithm whereby nodes rely only on local information exchanges with their neighbors to attain global optimality. Simulations confirm that the distributed online algorithm does not require knowledge of the underlying fading channel distribution and converges to the optimum almost surely from any initialization.